package com.retirement.trusteeship.controller;

import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.core.page.TableDataInfo;
import com.retirement.trusteeship.domain.OldTrusteeship;
import com.retirement.trusteeship.dto.OldTrusteeshipDto;
import com.retirement.trusteeship.service.IOldTrusteeshipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijy
 * @since 2024-01-03
 */
@Api(value = "托管管理", tags = "托管管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/trusteeship")
public class OldTrusteeshipController extends BaseController {

    private final IOldTrusteeshipService iOldTrusteeshipService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询托管订单")
    public TableDataInfo listTrusteeship(OldTrusteeshipDto dto){
        startPage();
        return getDataTable(iOldTrusteeshipService.listTrusteeship(dto));
    }

    @PostMapping
    @ApiOperation(value = "新增托管订单")
    public AjaxResult addTrusteeship(@RequestBody OldTrusteeship dto){
        return AjaxResult.success(iOldTrusteeshipService.addTrusteeship(dto));
    }

    @PutMapping
    @ApiOperation(value = "修改订单")
    public AjaxResult updateTrusteeship(@RequestBody OldTrusteeship dto){
        return AjaxResult.success(iOldTrusteeshipService.updateTrusteeship(dto));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除预约")
    public AjaxResult deleteTrusteeship(@PathVariable("id") String id){
        return AjaxResult.success(iOldTrusteeshipService.deleteTrusteeship(id));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "查询订单详情")
    public OldTrusteeship getDetail(@PathVariable("id") String id){
        return iOldTrusteeshipService.getById(id);
    }



}
